{template 'public/header'}

{template 'public/comhead'}
<link rel="stylesheet" type="text/css" href="../addons/yzzc_sun/template/public/ygcsslist.css">
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>
    <li  {if $type=='all'} class="active" {/if}><a href="{php echo $this->createWebUrl('order',array('type'=>all,'status'=>6));}">全部订单</a></li>
    <li   {if $type=='wait'} class="active" {/if}><a href="{php echo $this->createWebUrl('order',array('type'=>wait,'status'=>1,'refund'=>$refund,'istui'=>$istui,'del'=>$del,'isdel'=>$isdel));}">待支付</a></li>
    <li   {if $type=='ok'} class="active" {/if}><a href="{php echo $this->createWebUrl('order',array('type'=>ok,'status'=>2,'refund'=>$refund,'istui'=>$istui,'del'=>$del,'isdel'=>$isdel));}">已支付</a></li>
    <li   {if $type=='no'} class="active" {/if}><a href="{php echo $this->createWebUrl('order',array('type'=>no,'status'=>3,'refund'=>$refund,'istui'=>$istui,'del'=>$del,'isdel'=>$isdel));}">已取车</a></li>
    <li   {if $type=='finish'} class="active" {/if}><a href="{php echo $this->createWebUrl('order',array('type'=>finish,'status'=>0,'refund'=>$refund,'istui'=>$istui,'del'=>$del,'isdel'=>$isdel));}">已完成</a></li>
    <li   {if $type=='qx'} class="active" {/if}><a href="{php echo $this->createWebUrl('order',array('type'=>qx,'status'=>4,'refund'=>$refund,'istui'=>$istui,'del'=>$del,'isdel'=>$isdel));}">已取消</a></li>
<!--    <li   {if $type=='tk'} class="active" {/if}><a href="{php echo $this->createWebUrl('order',array('type'=>tk,'status'=>5,'refund'=>$refund,'istui'=>$istui,'del'=>$del,'isdel'=>$isdel));}">退款成功</a></li>-->
</ul>
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">退款处理:</div>
    <li   {if $refund=='refund'} class="active" {/if}><a href="{php echo $this->createWebUrl('order',array('refund'=>refund,'istui'=>1,'type'=>$type,'status'=>$status,'del'=>$del,'isdel'=>$isdel));}">未处理</a></li>
    <li   {if $refund=='refundno'} class="active" {/if}><a href="{php echo $this->createWebUrl('order',array('refund'=>refundno,'istui'=>3,'type'=>$type,'status'=>$status,'del'=>$del,'isdel'=>$isdel));}">退款失败</a></li>
    <span class="ygxian"></span>
    <div class="ygdangq">退押金处理:</div>
    <li   {if $deposit=='refund'} class="active" {/if}><a href="{php echo $this->createWebUrl('order',array('deposit'=>refund,'isdeposit'=>1,'type'=>$type,'status'=>$status,'del'=>$del,'isdel'=>$isdel));}">未处理</a></li>
    <li   {if $deposit=='refundyes'} class="active" {/if}><a href="{php echo $this->createWebUrl('order',array('deposit'=>refundyes,'isdeposit'=>2,'type'=>$type,'status'=>$status,'del'=>$del,'isdel'=>$isdel));}">退押金成功</a></li>
    <li   {if $deposit=='refundno'} class="active" {/if}><a href="{php echo $this->createWebUrl('order',array('deposit'=>refundno,'isdeposit'=>3,'type'=>$type,'status'=>$status,'del'=>$del,'isdel'=>$isdel));}">退押金失败</a></li>
    <span class="ygxian"></span>
    <div class="ygdangq">删除处理:</div>
    <li   {if $del=='del'} class="active" {/if}><a href="{php echo $this->createWebUrl('order',array('del'=>del,'isdel'=>0,'refund'=>$refund,'istui'=>$istui,'type'=>$type,'status'=>$status,'deposit'=>$deposit,'isdeposit'=>$isdeposit));}">已删除</a></li>
</ul>

<div class="row ygrow">
    <div class="col-lg-12">
        <form class="form-inline" action="" method="get">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="yzzc_sun" />
            <input type="hidden" name="do" value="order" />
            <input type="hidden" name="token" value="{$_W['token']}"/>
            <div class="form-group">
                <label for="keyword">关键词</label>
                <input type="text" class="form-control" name="keywords" id="keyword" value="{$keywords}" placeholder="请输入订单号，车牌号，交车员">
            </div>
            <div class="form-group">
                <label for="branch_id">门店</label>
                <select class="form-control" id="branch_id" name="branch_id" style="width: 150px">
                    <option value="">请选择门店</option>
                    {loop $branch_list $index $item}
                    <option value="{$item['id']}" {if $branch_id == $item['id'] } selected {/if}>{$item['name']}</option>
                    {/loop}
                </select>
            </div>
            <div class="form-group">
                <label for="distribution_id">经办人</label>
                <select class="form-control" id="distribution_id" name="distribution_id" style="width: 150px">
                    <option value="">请选择经办人</option>
                    {loop $distribution_list $index $item}
                    <option value="{$item['uid']}" {if $distribution_id == $item['uid'] } selected {/if}>{$item['name']}</option>
                    {/loop}
                </select>
            </div>
            <div class="form-group">
                <label>创建时间</label>
                {php echo tpl_form_field_daterange('range_time',array('start'=>date('Y-m-d H:i', $start_time),'end'=>date('Y-m-d H:i', $end_time)),true);}
            </div>
            <input type="submit"  name="submit"  value="搜索" class="btn btn-default">
        </form>
    </div>
</div>
<!--<div class="row ygrow">-->
<!--    <div class='col-lg-12'>-->
<!--        <a  href="{php echo $this->createWebUrl('order',array('op'=>'booking'));}"><button class="btn btn-sm store-blue">预约下单</button></a>-->
<!--    </div>-->
<!--</div>-->
<div class="row ygrow">
    <div class="col-lg-12">
        <a data-toggle="modal" data-target="#myModalsss"><button class="btn btn-xs storeblue">导出客户租车信息</button></a>
        <div class="modal fade" id="myModalsss" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
          <div class="modal-dialog" role="document">
                <div class="modal-content">
                  <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">客户租车信息导出</h4>
                  </div>
                  <form action="" method="get" >
                      <input type="hidden" name="c" value="site" />
                      <input type="hidden" name="a" value="entry" />
                      <input type="hidden" name="m" value="yzzc_sun" />
                      <input type="hidden" name="do" value="order" />
                      <input type="hidden" name="status" value="{$status}" />
                      <input type="hidden" name="op" value="exportorder" />
                      <div class="modal-body" style="font-size: 20px">
                            <span>
                            {if $status ==1}即将导出待支付订单？
                            {elseif $status == 2 }即将导出已支付订单？
                            {elseif $status == 3 }即将导出已取车订单？
                            {elseif $status == 4 }即将导出已取消订单？
                            {elseif $status == 0 }即将导出已完成订单？
                            {elseif $status == 5 }即将导出已退款订单？
                            {elseif $status == 6 }即将导出所有订单？
                            {else}即将导出所有订单？
                            {/if}
                            </span>
                      </div>

                      <div class="modal-footer">
                          <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                          <input type="submit" class="btn btn-info" name="submit" value="确定"/>
                      </div>
                      <input type="hidden" name="token" value="{$_W['token']}"/>
                  </form>
                </div>
              </div>
          </div>
        <!-- <form action="" method="get" class="col-md-4">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="yzzc_sun" />
            <input type="hidden" name="do" value="order" />
            <input type="hidden" name="op" value="exportorder" />
            <div class="input-group">
                <span class="input-group-btn">
                    <input type="submit" class="btn btn-default" name="submit" value="导出客户租车信息"/>
                </span>
            </div>
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </form>

        <div class="col-md-4">
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </div> -->
    </div>
</div>
<div class="main ">
    <div class="panel panel-default">
        <!--<div class="panel-body ygbtn">-->
            <!--<div class="btn ygshouqian2" id="allselect">批量删除</div>-->
            <!--<div class="btn ygyouhui2" id="allpass">批量通过</div>-->
            <!--<div class="btn storegrey2" id="allrefuse">批量拒绝</div>-->
        <!--</div>-->
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">
            订单列表
        </div>
        <div class="panel-body" style="padding: 0px 15px;">
            <div class="row">
                <table class="yg5_tabel col-md-12">
                    <tr class="yg5_tr1">
                        <!--<td class="store_td1 col-md-1" style="text-align: center;">-->
                            <!--<input type="checkbox" class="allcheck" />-->
                            <!--<span class="store_inp">全选</span>-->
                        <!--</td>-->
                        <td class="store_td1 col-md-1">订单号</td>
                        <td style="width: 5.333333%">取还方式</td>
                        <td style="width: 5.333333%">车辆来源</td>
                        <td class="col-md-1">门店名称</td>
                        <td class="col-md-1">车辆名称（车牌号）</td>
                        <td class="col-md-2">租车时间</td>
                        <td style="width: 4.333333%">总天数</td>
                        <td style="width: 10.333333%">送车员</td>
                        <td style="width: 10.333333%">还车员</td>
                        <td style="width: 5.333333%">订单总金额</td>
<!--                        <td style="width: 6.333333%">实付 / 续租费</td>-->
                        <td class="col-md-1">取车名称 / 手机</td>
                        <td class="col-md-1">费用完善</td>
                        <td class="">支付方式</td>
                        <td class="">订单状态</td>
                        <td class="">订单类型</td>
                        <td class="">开发票</td>
                        <td class="col-md-3">操作</td>
                    </tr>
                    {loop $list $key $item}
                    <tr class="yg5_tr2">
                        <!--<td>-->
                            <!--<input type="checkbox" name="test" value="{$item['id']}">-->
                        <!--</td>-->
                        <td>{$item['ordernum']}</td>
                        {if $item['gettype']==1}
                        <td>门店取还</td>
                        {else}
                        <td>送车上门</td>
                        {/if}
                        <td>
                            {if $item['is_inner']==1}
                            自有
                            {else}
                            外调
                            {/if}
                        </td>
                        <td>{$item['shopname']}</td>
                        <td>{$item['car_name']}({$item['carnum']})</td>
                        <td>{$item['start_time']} <br>~<br> {$item['end_time']}</td>
                        <td>{$item['day']}</td>
                        <td>{$item['shuttle_name']}
                            (
                            {if $item['gettype']==1}
                            门店
                            {else}
                            上门
                            {/if}
                            )
                        </td>
                        <td>
                            {if $item['reclaim_shuttle_name']}
                            {$item['reclaim_shuttle_name']}(
                            {if $item['is_onsite']==1}
                            上门
                            {else}
                            门店
                            {/if}
                            )
                            {/if}
                        </td>
                        <td>{$item['total_money']}</td>
<!--                        <td>{$item['prepay_money']} / {$item['xzmoney']}</td>-->
                        <td>{$item['username']} / {$item['tel']}</td>
                        <td>
                            {if $item['is_fees']==1}
                            <span class="label store-green btn">完善</span>
                            {else}
                            <span class="label store-red btn">未完善</span>
                            {/if}
                        </td>
                        <td>
                            {if $item['pay_type']==1}
                            <span class="label store-yellow btn">线上支付</span>
                            {else}
                            <span class="label store-red btn">线下收款</span>
                            {/if}
                        </td>
                        <td>
                        {if $item['display']==1}
                            {if $item['status']==1}
                            <!-- <td> -->
                                <span class="label store-yellow btn">待支付</span>
                            <!-- </td > -->
                            {elseif $item['status']==2}
                            <!-- <td > -->
                                <span class="label store-red btn">已支付</span>
                            <!-- </td> -->
                            {elseif $item['status']==3}
                            <!-- <td> -->
                                <span class="label store-green btn">已取车</span>
                            <!-- </td> -->
                            {elseif $item['status']==4}
                            <!-- <td> -->
                                <span class="label store-disable btn">已取消</span>
                            <!-- </td> -->
                            {elseif $item['status']==0}
                                <span class="label store-green btn">已完成</span>
                            {/if}
                            {if $item['istui']==2}
                                  <span class="label store-green btn" style="top: 10px;position: relative">退款成功</span>
                            {elseif $item['istui']==3}
                                  <span class="label store-yellow btn" style="top: 10px;position: relative">退款失败</span>
                            {elseif $item['istui']==1}
                                  <span class="label store-blue btn" style="top: 10px;position: relative">退款申请中</span>
                            {/if}

                            {if $item['isdeposit']==2}
                                  <span class="label store-green btn" style="top: 10px;position: relative">退押金成功</span>
                            {elseif $item['isdeposit']==3}
                                  <span class="label store-yellow btn" style="top: 10px;position: relative">退押金失败</span>
                            {elseif $item['isdeposit']==1}
                                  <span class="label store-blue btn" style="top: 10px;position: relative">退押金申请中</span>
                            {/if}
                            {if $item['iszx']==1}
                                  <span class="label store-grey btn" style="top: 10px;position: relative">已续租</span>
                            {/if}
                        {else}
                              <span class="label store-disable btn">已删除</span>
                    
                        {/if}
                        </td>
                        <td>
                            {if $item['source_type']==1}
                            <!-- <td> -->
                            <span class="label store-red btn">客户下单</span>
                            {else}
                            <span class="label store-blue btn">预订下单</span>
                            <!-- </td> -->
                            {/if}
                        </td>
                        <td>
                            {if $item['is_invoice']==1}
                            <!-- <td> -->
                            <span class="label store-red btn">需要开票</span>
                            {else}
                            <span class="label store-blue btn">不需要</span>
                            <!-- </td> -->
                            {/if}
                        </td>
                        <td>
                            {if $item['status']!=0}
                            <a href="{php echo $this->createWebUrl('order',array('op'=>'cancel','id'=>$item['id']));}"><button class="btn storeblue btn-xs">取消</button></a>
                            <a data-toggle="modal" data-target="#myModalssssss"><button class="btn store-blue btn-xs">修改租金</button></a>
                            <div class="modal fade" id="myModalssssss" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                              <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                                      <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                        <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">修改总租金</h4>
                                      </div>
                                      <form action="" method="get" >
                                          <input type="hidden" name="c" value="site" />
                                          <input type="hidden" name="a" value="entry" />
                                          <input type="hidden" name="m" value="yzzc_sun" />
                                          <input type="hidden" name="do" value="order" />
                                          <input type="hidden" name="op" value="update" />
                                          <input type="hidden" name="id" value="{$item['id']}" />
                                          <div class="modal-body" style="font-size: 20px">
                                                <label class="col-xs-12 col-sm-3 col-md-2 control-label">支付金额</label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="prepay_money" class="form-control" value="{$item['prepay_money']}" />
                                                </div>
                                          </div>

                                          <div class="modal-footer">
                                              <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                              <input type="submit" class="btn btn-info" name="submit" value="确定"/>
                                          </div>
                                          <input type="hidden" name="token" value="{$_W['token']}"/>
                                      </form>
                                    </div>
                                  </div>
                            </div>
                            {/if}

<!--                            {if $item['status']==2}
                            <a href="{php echo $this->createWebUrl('order',array('op'=>'return','id'=>$item['id'],'type'=>1));}"><button class="btn store-green btn-xs">交车</button></a>
                            {/if}
                            {if $item['status']==3}
                            <a href="{php echo $this->createWebUrl('order',array('op'=>'return','id'=>$item['id'],'type'=>2));}"><button class="btn store-green btn-xs">还车</button></a>
                            {/if}-->
                            {if $item['status']==0}
                            <a href="{php echo $this->createWebUrl('order',array('op'=>'fees','id'=>$item['id']));}"><button class="btn store-blue btn-xs">完善费用</button></a>
                            {/if}
                            {if $item['ispl']==1}
                            <a href="{php echo $this->createWebUrl('orderpj',array('id'=>$item['id']));}"><button class="btn store-blue btn-xs">验车评价</button></a>
                            {/if}
                            <a href="{php echo $this->createWebUrl('orderjsy',array('id'=>$item['id']));}"><button class="btn store-blue btn-xs">详情</button></a>

                            {if $item['istui']==1}
                                <a href="{php echo $this->createWebUrl('order', array('op'=>refund,'id'=>$item['id'],'refund'=>2))}"><button class="btn btn-xs storeblue">通过退款申请</button></a>
                                <a href="{php echo $this->createWebUrl('order', array('op'=>refund,'id'=>$item['id'],'refund'=>3))}"><button class="btn btn-xs storeblue">拒绝退款申请</button></a>
                            {/if}
                            {if $item['isdeposit']==1}
                            <div class="modal fade" id="refundDeposit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                                <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                            <h4 class="modal-title" id="refundDepositLabel" style="font-size: 20px;">退款押金</h4>
                                        </div>
                                        <form action="" method="get" >
                                            <input type="hidden" name="c" value="site" />
                                            <input type="hidden" name="a" value="entry" />
                                            <input type="hidden" name="m" value="yzzc_sun" />
                                            <input type="hidden" name="do" value="order" />
                                            <input type="hidden" name="op" value="refunddeposit" />
                                            <input type="hidden" name="id" value="{$item['id']}" />
                                            <div class="modal-body" style="font-size: 20px">
                                                <label class="col-xs-12 col-sm-3 col-md-2 control-label">退款押金</label>
                                                <div class="col-sm-3">
                                                    <input type="text" name="deposit_money" class="form-control" value="{$item['deposit_money']}" />
                                                </div>
                                            </div>
                                            <div class="modal-footer">
                                                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                                <input type="submit" class="btn btn-info" name="submit" value="确定"/>
                                            </div>
                                            <input type="hidden" name="token" value="{$_W['token']}"/>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <a data-toggle="modal" data-target="#refundDeposit"><button class="btn btn-xs store-green">退押金</button></a>
<!--                                <a href="{php echo $this->createWebUrl('order', array('op'=>refunddeposit,'id'=>$item['id'],'refund'=>2))}"><button class="btn btn-xs storeblue">通过退押金申请</button></a>-->
                                <a href="{php echo $this->createWebUrl('order', array('op'=>refunddeposit,'id'=>$item['id'],'refund'=>3))}"><button class="btn btn-xs store-red ">拒绝退押金</button></a>
                            {/if}
                            {if $item['status'] !=2 && $item['status']!=3 &&$item['display']==1}
                            <a href="javascript:void(0);" class="storespan btn btn-xs" data-toggle="modal" data-target="#myModal{$item['id']}">
                                <span class="fa fa-trash-o"></span>
                                <span class="bianji">删除
                                    <span class="arrowdown"></span>
                                </span>
                            </a>
                            {/if}
                        </td>
                    </tr>
                    <div class="modal fade" id="myModal{$item['id']}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">提示</h4>
                                </div>
                                <div class="modal-body" style="font-size: 20px">
                                    确定删除么？
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                    <a href="{php echo $this->createWebUrl('order', array('op' => 'delete', 'oid' => $item['id']))}" type="button" class="btn btn-info" >确定</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    {/loop}
                    {if empty($list)}
                    <tr class="yg5_tr2">
                        <td colspan="8">
                            暂无订单信息
                        </td>
                    </tr>
                    {/if}
                </table>
            </div>
        </div>
    </div>
</div>
<div class="text-right we7-margin-top">
    {$pager}
</div>
<script type="text/javascript">
    $(function(){
        $("#frame-2").show();
        $("#yframe-2").addClass("wyactive");
        // ———————————————批量删除———————————————
        $("#allselect").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要删除的商品!');
                return false;
            }else if(confirm("确认要删除此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });

                $.ajax({
                    type:"post",
                    url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=order&op=delete&m=yzzc_sun",
                    dataType:"text",
                    data:{oid:id},
                    success:function(data){
                        console.log(data);
                        location.reload();
                    }
                })

            }
        });

        // ———————————————批量通过———————————————
        $("#allpass").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要通过的商品!');
                return false;
            }else if(confirm("确认要通过此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });
                console.log(id)
                $.ajax({
                    type:"post",
                    url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=Adoptorder&m=yzzc_sun",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);
                        location.reload();
                    }
                })
            }
        });

        // ———————————————批量拒绝———————————————
        $("#allrefuse").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要拒绝的商品!');
                return false;
            }else if(confirm("确认要拒绝此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });
                console.log(id)
                $.ajax({
                    type:"post",
                    url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=Rejectorder&m=yzzc_sun",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);
                        location.reload();
                    }
                })
            }
        });

        $(".allcheck").on('click',function(){
            var checked = $(this).get(0).checked;
            $("input[type=checkbox]").prop("checked",checked);
        });
    })
</script>